using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Konst3d.Efficiency.Suite;

namespace PEM
{
	/// <summary>
	/// Interaction logic for EditStatisticDayDialog.xaml
	/// </summary>
	public partial class EditStatisticDayDialog : PersistentModalDialog
	{
		#region Properties

		public float StatisticValue
		{
			get
			{
				return Single.Parse(uiStatisticValueLabel.Text);
			}
		}

		public string StatisticCommentary
		{
			get
			{
				return uiStatisticCommentaryTextBox.Text;
			}
		}

		#endregion // Properties

		public EditStatisticDayDialog()
		{
			InitializeComponent();
		}

		public bool ShowDialog(Window owner, IStatisticDay statisticDay)
		{
			if (statisticDay != null)
			{
				uiStatisticDateLabel.Content = statisticDay.Date.ToString("dd MM yyyy");
				uiStatisticValueLabel.Text = statisticDay.Value.ToString();
				uiStatisticCommentaryTextBox.Text = statisticDay.Commentary;
			}
			else
			{
				uiStatisticDateLabel.Content = String.Empty;
				uiStatisticValueLabel.Text = String.Empty;
				uiStatisticCommentaryTextBox.Text = String.Empty;
			}

			return ShowDialog(owner);
		}

		private void OnCreateButtonClick(object sender, RoutedEventArgs e)
		{
			DialogResult = true;
		}

		private void OnCancelButtonClick(object sender, RoutedEventArgs e)
		{
			DialogResult = false;
		}
	}
}
